/**
 * @param {number[][]} people
 * @return {number[][]}
 */

var reconstructQueue = function (people) {
    let len = people.length
    let queue = []
    // h降序排列 k升序
    people.sort((a, b) => {
        if (b[0] !== a[0]) {
            return b[0] - a[0]
        } else {
            return a[1] - b[1]
        }
    })
    for (let i = 0; i < len; i++) {
        queue.splice(people[i][1], 0, people[i])
    }
    return queue
};
console.log(reconstructQueue([[7, 1], [4, 4], [7, 0], [5, 0], [6, 1], [5, 2]]))